package com.example.view.activity;

import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.example.common.base.AbsActivity;
import com.example.view.R;
import com.example.view.databinding.ActImgAttrBinding;

/**
 * hint：ImageView 属性，5.0引入
 * backgroundTint,foregroundTint,drawableTint:背景、前景、drawable着色
 * 过滤器着色：setColorFilter(Color.parseColor("#fffa37"));
 * PorterDuffColorFilter
 * adjustViewBounds:
 * ColorStateList.valueOf(0xFF4CAF50)
 */
@Route(path = "/view/imageAttr")
public class ImgAttrActivity extends AbsActivity<ActImgAttrBinding> {

    private PorterDuffColorFilter filter;

    @Override
    protected int getLayoutId() {
        return R.layout.act_img_attr;
    }

    @Override
    protected void main() {
        //为图片重新着色，透明部分不会改变；只限src属性
        // mBinding.imageView.setColorFilter(Color.parseColor("#fffa37"));
        //
        if (filter == null) {
            // Cache miss, so create a color filter and add it to the cache
            filter = new PorterDuffColorFilter(getResources().getColor(R.color.pk_blue), PorterDuff.Mode.SRC_IN);
        }
        mBinding.imageView.setColorFilter(filter);
    }

    @Override
    protected void initListener() {

    }
}
